package com.vegetable.modules.mapper.finance;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vegetable.modules.entity.finance.vo.ExpenseDetailVO;
import com.vegetable.modules.entity.finance.vo.TrendDataVO;
import com.vegetable.modules.entity.finance.vo.ExpenseRatioDataVO;
import com.vegetable.modules.entity.finance.vo.CommoditySalesVO;
import com.vegetable.modules.entity.finance.vo.PackPurchaseVO;
import com.vegetable.modules.entity.finance.vo.CustomerSalesVO;
import com.vegetable.modules.entity.finance.vo.PackLossVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 项目盈利情况统计Mapper接口
 */
@Mapper
public interface ProjectProfitMapper {

    /**
     * 获取销售收入
     */
    BigDecimal getTotalSales(@Param("regionId") Integer regionId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 获取销售成本
     */
    BigDecimal getTotalCost(@Param("regionId") Integer regionId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 获取费用报销总额
     */
    BigDecimal getTotalReimbursement(@Param("regionId") Integer regionId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 获取采购费用总额
     */
    BigDecimal getTotalPurchaseCost(@Param("regionId") Integer regionId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 获取代办费用总额
     */
    BigDecimal getTotalAgentCost(@Param("regionId") Integer regionId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 获取加工费用总额
     */
    BigDecimal getTotalPackCost(@Param("regionId") Integer regionId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    /**
     * 获取费用报销明细列表
     */
    List<ExpenseDetailVO> getReimbursementDetails(@Param("regionId") Integer regionId, 
                                          @Param("startDate") Date startDate, 
                                          @Param("endDate") Date endDate,
                                          @Param("page") Long page,
                                          @Param("limit") Long limit);

    /**
     * 获取采购费用明细列表
     */
    List<ExpenseDetailVO> getPurchaseDetails(@Param("regionId") Integer regionId, 
                                          @Param("startDate") Date startDate, 
                                          @Param("endDate") Date endDate,
                                          @Param("page") Long page,
                                          @Param("limit") Long limit);

    /**
     * 获取代办费用明细列表
     */
    List<ExpenseDetailVO> getAgentDetails(@Param("regionId") Integer regionId, 
                                          @Param("startDate") Date startDate, 
                                          @Param("endDate") Date endDate,
                                          @Param("page") Long page,
                                          @Param("limit") Long limit);

    /**
     * 获取加工费用明细列表
     */
    List<ExpenseDetailVO> getPackDetails(@Param("regionId") Integer regionId, 
                                          @Param("startDate") Date startDate, 
                                          @Param("endDate") Date endDate,
                                          @Param("page") Long page,
                                          @Param("limit") Long limit);

    /**
     * 获取费用报销明细总数
     */
    Long getReimbursementDetailsCount(@Param("regionId") Integer regionId,
                               @Param("startDate") Date startDate,
                               @Param("endDate") Date endDate);

    /**
     * 获取采购费用明细总数
     */
    Long getPurchaseDetailsCount(@Param("regionId") Integer regionId,
                               @Param("startDate") Date startDate,
                               @Param("endDate") Date endDate);

    /**
     * 获取代办费用明细总数
     */
    Long getAgentDetailsCount(@Param("regionId") Integer regionId,
                               @Param("startDate") Date startDate,
                               @Param("endDate") Date endDate);

    /**
     * 获取加工费用明细总数
     */
    Long getPackDetailsCount(@Param("regionId") Integer regionId,
                               @Param("startDate") Date startDate,
                               @Param("endDate") Date endDate);

    /**
     * 获取收入趋势数据
     */
    List<TrendDataVO> getIncomeTrend(@Param("regionId") Integer regionId,
                                   @Param("startDate") Date startDate,
                                   @Param("endDate") Date endDate,
                                   @Param("type") String type);

    /**
     * 获取支出趋势数据
     */
    List<TrendDataVO> getExpenseTrend(@Param("regionId") Integer regionId,
                                    @Param("startDate") Date startDate,
                                    @Param("endDate") Date endDate,
                                    @Param("type") String type);

    /**
     * 获取费用报销占比
     */
    ExpenseRatioDataVO getReimbursementRatio(@Param("regionId") Integer regionId,
                                           @Param("startDate") Date startDate,
                                           @Param("endDate") Date endDate);

    /**
     * 获取采购费用占比
     */
    ExpenseRatioDataVO getPurchaseRatio(@Param("regionId") Integer regionId,
                                      @Param("startDate") Date startDate,
                                      @Param("endDate") Date endDate);

    /**
     * 获取代办费用占比
     */
    ExpenseRatioDataVO getAgentRatio(@Param("regionId") Integer regionId,
                                   @Param("startDate") Date startDate,
                                   @Param("endDate") Date endDate);

    /**
     * 获取加工费用占比
     */
    ExpenseRatioDataVO getPackRatio(@Param("regionId") Integer regionId,
                                  @Param("startDate") Date startDate,
                                  @Param("endDate") Date endDate);
                                  
    /**
     * 获取项目回款总额
     */
    BigDecimal getTotalCollection(@Param("regionId") Integer regionId, 
                                @Param("startDate") Date startDate, 
                                @Param("endDate") Date endDate);
                                
    /**
     * 按商品统计销售出库单金额(分页)
     */
    List<CommoditySalesVO> getSalesByCommodity(@Param("regionId") Integer regionId, 
                                             @Param("startDate") Date startDate, 
                                             @Param("endDate") Date endDate,
                                             @Param("commodityName") String commodityName,
                                             @Param("offset") Long offset,
                                             @Param("limit") Long limit);
                                
    /**
     * 按商品统计销售出库单总数
     */
    Long getSalesByCommodityCount(@Param("regionId") Integer regionId, 
                                @Param("startDate") Date startDate, 
                                @Param("endDate") Date endDate,
                                @Param("commodityName") String commodityName);
                                
    /**
     * 获取商品销售总统计数据
     */
    CommoditySalesVO getTotalSalesByCommodity(@Param("regionId") Integer regionId, 
                                            @Param("startDate") Date startDate, 
                                            @Param("endDate") Date endDate,
                                            @Param("commodityName") String commodityName);
                                
    /**
     * 统计包装类采购(分页)
     */
    List<PackPurchaseVO> getPackPurchaseDetails(@Param("regionId") Integer regionId, 
                                              @Param("startDate") Date startDate, 
                                              @Param("endDate") Date endDate,
                                              @Param("commodityName") String commodityName,
                                              @Param("supplierName") String supplierName,
                                              @Param("offset") Long offset,
                                              @Param("limit") Long limit);
                                
    /**
     * 统计包装类采购总数
     */
    Long getPackPurchaseDetailsCount(@Param("regionId") Integer regionId, 
                                   @Param("startDate") Date startDate, 
                                   @Param("endDate") Date endDate,
                                   @Param("commodityName") String commodityName,
                                   @Param("supplierName") String supplierName);
                                
    /**
     * 获取包装类采购总统计数据
     */
    PackPurchaseVO getTotalPackPurchase(@Param("regionId") Integer regionId, 
                                      @Param("startDate") Date startDate, 
                                      @Param("endDate") Date endDate,
                                      @Param("commodityName") String commodityName,
                                      @Param("supplierName") String supplierName);
                                
    /**
     * 按客户统计销售及回款数据(分页)
     */
    List<CustomerSalesVO> getSalesByCustomer(@Param("regionId") Integer regionId, 
                                           @Param("startDate") Date startDate, 
                                           @Param("endDate") Date endDate,
                                           @Param("customerName") String customerName,
                                           @Param("offset") Long offset,
                                           @Param("limit") Long limit);
                                
    /**
     * 按客户统计销售及回款数据总数
     */
    Long getSalesByCustomerCount(@Param("regionId") Integer regionId, 
                               @Param("startDate") Date startDate, 
                               @Param("endDate") Date endDate,
                               @Param("customerName") String customerName);
                                
    /**
     * 获取客户销售总统计数据
     */
    CustomerSalesVO getTotalSalesByCustomer(@Param("regionId") Integer regionId, 
                                          @Param("startDate") Date startDate, 
                                          @Param("endDate") Date endDate,
                                          @Param("customerName") String customerName);
                                
    /**
     * 统计加工订单损耗情况(分页)
     */
    List<PackLossVO> getPackLossDetails(@Param("regionId") Integer regionId, 
                                      @Param("startDate") Date startDate, 
                                      @Param("endDate") Date endDate,
                                      @Param("commodityName") String commodityName,
                                      @Param("offset") Long offset,
                                      @Param("limit") Long limit);
                                
    /**
     * 统计加工订单损耗情况总数
     */
    Long getPackLossDetailsCount(@Param("regionId") Integer regionId, 
                               @Param("startDate") Date startDate, 
                               @Param("endDate") Date endDate,
                               @Param("commodityName") String commodityName);
                               
    /**
     * 获取加工订单总损耗统计
     */
    PackLossVO getTotalPackLoss(@Param("regionId") Integer regionId, 
                              @Param("startDate") Date startDate, 
                              @Param("endDate") Date endDate,
                              @Param("commodityName") String commodityName);
}